*Program name:      data_appendix.do
*Written by:        Diane Alexander
*Date written:      February 11, 2021
*Last modified by:  Ezra Karger
*Date modified:     February 18, 2021

clear all


*Set sub-directory paths--same for all users:

global unacast  "${machine}/data/clean/unacast"
global stay_at_home "${machine}/data/clean/stay_at_home"
global womply "${machine}/data/clean/womply"
global nyt_cases "${machine}/data/clean/nyt_cases"
global census "${machine}/data/clean/census"
global trump "${machine}/data/clean/trump"
global acs "${machine}/data/clean/acs_2018"
global usda "${machine}/data/clean/usda_ers"
global weather "${machine}/data/clean/weather"
global covid_tracker "${machine}/data/clean/covid_tracker"
global safegraph "${machine}/data/clean/safegraph"

global outdata "${machine}/data/clean/"

global tables "${machine}/tables/event_time"
global figures "${machine}/figures/event_time"

capture log close
log using "${figures}/4_data_appendix.log", text replace


*Read in the county-date dataset used in our event studies

use "${outdata}/countydata_foreventtime", clear


*Calculate a measure of populous and unpopulous counties

preserve

*Use USDA population estimates from 2018 to split counties

tab date if !missing(pop_estimate_2018)
tab date if missing(pop_estimate_2018)


keep if !missing(pop_estimate_2018)

duplicates drop county_fips, force

sum pop_estimate_2018, d

list county_fips pop_estimate_2018 if pop_estimate_2018==152
list county_fips pop_estimate_2018 if pop_estimate_2018>=1e07 & !missing(pop_estimate_2018)

restore

sum distance visit pe_r_food pe_r_other pe_r_all log_pe_food log_pe_other log_pe_all if county_fips==48301

sum distance visit pe_r_food pe_r_other pe_r_all log_pe_food log_pe_other log_pe_all if county_fips==06037



*Analyze coverage of Womply data in January, 2020

keep if year(date)==2020 & month(date)==1
tab date

collapse (mean) merchants_all revenue_food revenue_other revenue_all pop_estimate_2018, by(county_fips)

sum merchants_all revenue_food revenue_other revenue_all, d

reg merchants_all pop_estimate_2018

clear
log close

